// 2025/4/9
// DNA序列

#include <iostream>
using namespace std;

int main() {
    string str; cin >> str;
    int sublen, cg = 0, Mcg = 0, Mpos = 0;
    int n = str.size(); 
    cin >> sublen;
    for(int i = 0; i < sublen; i++)
    {
        if(str[i] == 'C' || str[i] == 'G')
            cg++;
    }
    Mcg = cg;
    for(int i = sublen; i < n; i++)
    {
        if(str[i] == 'C' || str[i] == 'G')
            cg++;
        if(str[i - sublen] == 'C' || str[i - sublen] == 'G')
            cg--;
        if(cg > Mcg)
        {
            Mcg = cg;
            Mpos = i - sublen + 1;
        }
    }
    cout << str.substr(Mpos, sublen) << endl;
}
// 64 位输出请用 printf("%lld")